//
//  CorgiEmoticonButton.swift
//  weibo
//
//  Created by Corgi on 17/3/31.
//  Copyright © 2017年 cocoaHangTou. All rights reserved.
//

import UIKit

class CorgiEmoticonButton: UIButton {

    var emoticonModel: CorgiEmoticonModel? {
    
        didSet {
            self.isHidden = false
            
            if emoticonModel!.isEmoji {
                
                let code = ((emoticonModel?.code ?? "") as NSString)
                
                self.setTitle(code.emoji(), for: .normal)
                
                self.setImage(nil, for: .normal)
                
            } else {
                
                let image = UIImage(named: emoticonModel?.allPath ?? "", in: CorgiEmoticonTools.shared.emoticonsBundle, compatibleWith: nil)
                
                self.setImage(image, for: .normal)
                
                self.setTitle(nil, for: .normal)
            }
        }
    }
}
